﻿@using System.Linq.Expressions;
@using Microsoft.AspNetCore.Authorization;
@using Microsoft.Extensions.Logging
@using ThingsGateway.Admin.Application;
@using ThingsGateway.Admin.Blazor
@using ThingsGateway.Core.Extension
@using ThingsGateway.Gateway.Application
@namespace ThingsGateway.Plugin.SqlDB
@inject UserResoures UserResoures
@inherits BaseComponentBase

@if (SqlDBProducer._driverPropertys.IsHisDB)
{
    <MCardText>
        @AppService.I18n.T("历史表")
    </MCardText>

    <AppDataTable @ref="_datatable" TItem="SQLHistoryValue" SearchItem="SqlDBPageInput"
                  AddItem="object" EditItem="object" IsShowSelect=false
                  SearchModel="@_search" IsShowOperCol=true
                  QueryCallAsync="QueryCallAsync" FirstQuery=false
                    IsShowDetailButton IsShowQueryButton>
     <SearchTemplate>

         <PDateTimePicker @bind-Value="context.StartTime"
                          TimeFormat="TimeFormat.Hr24"
                          ViewType="DateTimePickerViewType.Compact">
             <ActivatorContent Context="dt">
                 <MTextField @bind-Value="context.StartTime" Label=@AppService.I18n.T(context.Description(x => x.StartTime))
                                        Clearable Class="my-1  mx-2 "
                                        Filled Outlined
                                        Readonly Dense
                                 @attributes="@dt.Attrs">
                     </MTextField>
                 </ActivatorContent>
                 </PDateTimePicker>

                 <PDateTimePicker @bind-Value="context.EndTime"
                                  TimeFormat="TimeFormat.Hr24"
                                  ViewType="DateTimePickerViewType.Compact">
                 <ActivatorContent Context="dt">
                     <MTextField @bind-Value="context.EndTime" Label=@AppService.I18n.T(context.Description(x => x.EndTime))
                                        Clearable Class="my-1  mx-2 "
                                        Filled Outlined
                                        Readonly Dense
                                 @attributes="@dt.Attrs">
                     </MTextField>
                 </ActivatorContent>
                 </PDateTimePicker>



                 <MTextField Dense Style="max-width:200px;" HideDetails=@("auto") Class="my-1 mx-2 " Outlined
                         @bind-Value="context.VariableName" Label=@AppService.I18n.T(context.Description(x => x.VariableName)) />



         </SearchTemplate>


         </AppDataTable>


}
@if (SqlDBProducer._driverPropertys.IsReadDB)
{
    <MCardText>
        @AppService.I18n.T("实时表")
    </MCardText>
    <AppDataTable @ref="_datatable" TItem="SQLRealValue" SearchItem="SqlDBPageInput"
                  AddItem="object" EditItem="object" IsShowSelect=false
                  SearchModel="@_searchReal" IsShowOperCol=true
                  QueryCallAsync="RealQueryCallAsync" FirstQuery=false
                    IsShowDetailButton IsShowQueryButton>
     <SearchTemplate>

         <MTextField Dense Style="max-width:200px;" HideDetails=@("auto") Class="my-1 mx-2 " Outlined
                         @bind-Value="context.VariableName" Label=@AppService.I18n.T(context.Description(x => x.VariableName)) />


         </SearchTemplate>


         </AppDataTable>


}
